//
//  TextNameViewController.m
//  PerfectWorld
//
//  Created by dllo on 16/9/22.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "TextNameViewController.h"
#import "NetworkHandler.h"
#import "Masonry.h"
@interface TextNameViewController ()
@property (nonatomic, strong)UITextField *textFieldName;

@end

@implementation TextNameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账号设置";
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(clickLeftBtn:)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(clickRightBtn:)];
    [self creatSubView];
}
- (void)creatSubView {
    _textFieldName = [[UITextField alloc] init];
    _textFieldName.placeholder = @"请输入用户名";
    [self.view addSubview:_textFieldName];
    [_textFieldName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (100);
        make.left.mas_equalTo (15);
        make.width.mas_equalTo (self.view.frame.size.width - 30);
        make.height.mas_equalTo (50);
    }];
}


- (void)clickRightBtn:(UIBarButtonItem *)sender {
    if (_textFieldName.text != nil) {
        [self handData];
    }
}
- (void)handData {
    NSString *strUrl = @"http://api.guju.com.cn/v2/user/register";
    NSString *strBody = [NSString stringWithFormat:@"password=%@&phone=%@&user=%@", _passWorld, _login, _textFieldName.text];
    [NetworkHandler getDataByUrlString:strUrl BodyString:strBody WithDataBlock:^(id result) {
        NSLog(@"%@", result);
    }];
}
- (void)clickLeftBtn:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
